<script setup lang="ts">
import { computed, ref } from 'vue'
const showPopover = ref(false)

const props = defineProps<{
  disabled: boolean
}>()

const actions = computed(() => [
  { text: '查看处方', disabled: props.disabled },
  { text: '删除订单' }
])

const emit = defineEmits<{ (e: 'on-preview'): void; (e: 'on-delete'): void }>()

const onSelect = (action: { text: string }, i: number) => {
  if (i === 0) {
    emit('on-preview')
  }
  if (i === 1) {
    // 删除
    emit('on-delete')
  }
}
</script>

<template>
  <div class="more">
    <van-popover
      v-model:show="showPopover"
      :actions="actions"
      placement="top-start"
      @select="onSelect"
    >
      <template #reference>
        <span>更多</span>
      </template>
    </van-popover>
  </div>
</template>

<style lang="scss" scoped>
.more {
  color: var(--cp-tag);
  flex: 1;
  font-size: 13px;
}
</style>
